package com.harvest.scientific.ladder.page.fa

import android.graphics.Color
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import com.harvest.scientific.ladder.R
import com.harvest.scientific.ladder.base.BaseFragment
import com.harvest.scientific.ladder.databinding.OrderRefusedFragmentBinding
import com.harvest.scientific.ladder.ext.setMaterialDrawable
import com.harvest.scientific.ladder.ext.visible
import com.harvest.scientific.ladder.page.ui.main.MainViewModel
import com.harvest.scientific.ladder.util.LogUtils
import com.harvest.scientific.ladder.util.StbarUtil
import com.harvest.scientific.ladder.widget.BaseActionBar
import kotlinx.coroutines.launch

/**
 * bytedance
 * @author zenglw
 * @date   2024/6/12 21:17
 */
class RefusedFragment: BaseFragment<OrderRefusedFragmentBinding>() {

    private val viewModel by viewModels<MainViewModel> ({ requireActivity()})

    override fun initPage() {
        super.initPage()

        initListener()
    }

    private fun initListener() {

        lifecycleScope.launch {
            launch {

                viewModel.dislikeRoughSpe.collect { data ->
                    LogUtils.d("refusedfragment data->$data")
                    _binding.nextCreditTv.visible(data != null && data.rightPasserCivilRainbow.isNotEmpty()) {
                        _binding.nextCreditTv.text = getString(R.string.heure_du_prochain_pr_t_disponible_xx_xx_xxxx, data.rightPasserCivilRainbow)
                    }

                }
            }
        }
    }

    override fun setStatus(actionBar: BaseActionBar) {
        actionBar.apply {
            setTitle(getString(R.string.app_name))
            setBlackMode(true)
            _parentBinding.root.setMaterialDrawable(0f, Color.WHITE)
            StbarUtil.setStatusBar(requireActivity(), true, Color.TRANSPARENT, true)
        }
    }

    companion object {
        fun newInstance() = RefusedFragment()
    }
}